package netudp;

import java.net.InetSocketAddress;

/**
 * EventLog >
 *
 * data appear as POJO which saves configures, log or real 
 * message unit is a "event", we call it `LogEvent`
 */
public final class LogEvent {
    
    public static final byte SEPARATOR = (byte) ':';

    private final InetSocketAddress source;
    private final String logfile;
    private final String msg;
    private final long received;

    // constructor used for going out message
    public LogEvent(String logfile, String msg) {
        this(null, -1, logfile, msg);
    }

    // constructor used for coming message
    public LogEvent(InetSocketAddress source, long received, String logfile, String msg) {
        this.source = source;
        this.received = received;
        this.logfile = logfile;
        this.msg = msg;
    }
    
    // return address who sends the resource
    public InetSocketAddress getSource() {
        return source;
    }

    // return LogEvent name
    public String getLogfile() {
        return logfile;
    }

    // return message context
    public String getMsg() {
        return msg;
    }

    // return time receveid
    public long getReceived() {
        return received;
    }
}
